package com.example.dakotanews.dto;

import com.example.dakotanews.entity.comment.NewsComment;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @description 通用评论类，数据结构与接口文档中 获取评论接口 响应体结构中的data中内容的数据结构保持一致
 * 因为返回给前端的数据结构和数据表中的结构有些不同，并且该类的结构可在博客评论的相关接口中复用，因此单独创建了一个类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommentDTO {

    private Integer id;
    private Integer userId;
    private String nickname;
    private String profile;
    private String comment;
    private String commitTime;
    private int supportNum;
    private int supportIf;
    private List<ChildCommentDTO> childComments;
    private int childCommentNum;

    public CommentDTO(NewsComment newsComment) {
        this.userId = newsComment.getUserId();
        this.id = newsComment.getId();
        this.comment = newsComment.getComment();
        this.supportNum = newsComment.getSupportNum();
    }
}
